<!-- <html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>系统时间</title>
</head>
 
<body>
    <script>
        Date.prototype.format = function (fmt) {
            var o = {
                "y+": this.getFullYear, //年
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "h+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds() //秒
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }
        setInterval("document.getElementById('dateTime').innerHTML = (new Date()).format('yyyy-MM-dd hh:mm:ss');", 1000);
    </script>
 
    <div id="dateTime"></div>
</body> -->

<!-- 
<html>
<title>当前时间</title>

<body>
    <span id="cg">2016.12.21 上午12:00:00</span>
    <script>
        setInterval("cg.innerHTML=new Date().toLocaleString()", 1000);
    </script>
</body>
</html> -->


<html>

<head>

    <title>网页中动态的显示系统日期时间</title>

    <script language="JavaScript">
        function startTime() {
            var today = new Date();                 //定义日期对象  
            var yyyy = today.getFullYear();         //通过日期对象的getFullYear()方法返回年   
            var MM = today.getMonth() + 1;          //通过日期对象的getMonth()方法返回年   
            var dd = today.getDate();               //通过日期对象的getDate()方法返回年    
            var hh = today.getHours();              //通过日期对象的getHours方法返回小时  
            var mm = today.getMinutes();            //通过日期对象的getMinutes方法返回分钟  
            var ss = today.getSeconds();            //通过日期对象的getSeconds方法返回秒  

            MM = checkTime(MM);
            dd = checkTime(dd);
            mm = checkTime(mm);
            ss = checkTime(ss);

            var day; //用于保存星期（getDay()方法得到星期编号）
            if (today.getDay() == 0) day = "星期日 "
            if (today.getDay() == 1) day = "星期一 "
            if (today.getDay() == 2) day = "星期二 "
            if (today.getDay() == 3) day = "星期三 "
            if (today.getDay() == 4) day = "星期四 "
            if (today.getDay() == 5) day = "星期五 "
            if (today.getDay() == 6) day = "星期六 "

            document.getElementById('nowDateTimeSpan').innerHTML = yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm 
            setTimeout('startTime()', 1000);//每一秒中重新加载startTime()方法
        }

        function checkTime(i) {
            if (i < 10) {
                i = "0" + i;
            }
            return i;
        }
    </script>

</head>

<body onload="startTime()">

    时间：<font color=#000><span id="nowDateTimeSpan"></span></font>

</body>

</html>